<?php
 
defined("_VALID_ACCESS") || die('Direct access forbidden');
 
class SCTV_OptionsCommon extends ModuleCommon {
 
    public static function menu() {
 
        return array(__('SCTV') => array('__submenu__' => 1, __('Options') => array())); // - this will output as Module->HelloWorld in the main menu
 
    }
	
	public static function get_contract_number($year)
	{		
		$contract_number = Variable::get('contract_number_'.$year, false);
		if($contract_number == '') $contract_number = 0;		
		return $contract_number;
	}
	public static function get_contract_code()
	{
		$year = date('y');
		$contract_number = SCTV_OptionsCommon::get_contract_number($year);
		$contract_number = $contract_number + 1;
		return str_pad($contract_number, 5, '0', STR_PAD_LEFT) . 'A' . $year;
	}
	
	public static function set_contract_number($contract_code)
	{
		// Tach so hop dong
		$year = date('y');
		$contract_number = str_replace('A' . $year, '', $contract_code);
		Variable::set('contract_number_'.$year, $contract_number);
	}
	public static function get_bundle_number($year)
	{
		$bundle_number = Variable::get('bundle_number_'.$year, false);
		if($bundle_number == '') $bundle_number = 0;		
		return $bundle_number;
	}
	public static function get_bundle_code()
	{
		$year = date('y');
		$bundle_number = SCTV_OptionsCommon::get_bundle_number($year);
		$bundle_number = $bundle_number + 1;		
		return str_pad($bundle_number, 5, '0', STR_PAD_LEFT) . '/' . $year;
	}
	public static function set_bundle_number($bundle_code)
	{
		$year = date('y');
		$bundle_number = str_replace('/' . $year, '', $bundle_code);
		Variable::set('bundle_number', $bundle_number);
	}
}
 
?>